package com.example.pertecttime.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.pertecttime.R;

/**
 * Created by 半生瓜 on 2017/7/25.
 */

public class MyListViewAdapter extends BaseAdapter {
    private LayoutInflater mInflater = null;
    private String[] data;

    public MyListViewAdapter(Context context, String[] data) {
        this.data = data;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return data.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = mInflater.inflate(R.layout.test_listview_item, null);
            holder.title = (TextView) convertView.findViewById(R.id.text1);
            holder.test = (TextView) convertView.findViewById(R.id.text3);
            convertView.setTag(holder);


        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.title.setText(data[position]);
        holder.test.setText(data[position]);


        return convertView;
    }

    static class ViewHolder {
        public TextView title;
        public TextView test;
    }
}
